﻿@{
    ViewBag.Title = "内容管理";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@model UcAsp.Net.Model.EditArtices
<script type="text/javascript">
    tinymce.init({
        selector: "textarea",
        plugins: [
        "advlist autolink lists link image charmap print preview anchor",
        "searchreplace visualblocks code fullscreen",
        "insertdatetime media table contextmenu paste hr upfile"
    ],
        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent |link image upfile"

    });
    var inputname = new Array();
     var i=0;
    $(function () {
       
        $(".save").click(function () {
            $(".form-horizontal").find("input[type = 'file']").each(function (index) {
                inputname.push($(this).attr("id"));
                
            })
            UploadFile();
        })

        $(".show").click(function () {

            $(".form-horizontal").find("input[type = 'file']").each(function (index) {
                var inputname = $(this).attr("id")
                alert($("#File" + inputname).val());
            })


        })
    });
     function UploadFile() {
        $.upload({
            url: '/UploadFile.ashx',
            fileName: inputname,
            dataType: 'xml',
            onSend: function () {
                return true;
            },
            //上传之后回调
            onComplate: function (data) {
                if (data != null) {
                    if (data != "nofile") {
                        $("#File" + inputname[i]).val(data);
                    }
                }
                i++;
                if (i < inputname.length)
                {
                    UploadFile();
                }else
                {
                    $.post("/admin/SaveArtices", {@(new HtmlString(Model.EditJS))}, function () {
                    alert("保存完毕")
                    })
                }
            }
        });
    }
</script>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        项目列表</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="#" method="post" class="form-horizontal">
                    @(new HtmlString(Model.EditHTML))
                    </form>
                    <div class="control-group">
                        <div class="controls">
                            <span class="btn save">保存</span></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
